{% extends 'admin-v2/layout.html.twig' %}

{% set menu = 'admin_v2_item_bank_exercise' %}

{% set script_controller = 'item-bank-exercise/manage' %}

{% block main %}
  <div class="well well-sm mtl">
    <form id="exercise-search-form" class="form-inline" action="" method="get" novalidate>
      <div class="mbm">
        <div class="form-group">
          <select style="width:150px;" class="form-control" name="categoryId">
            <option value="">{{'admin.question_bank.manage.category'|trans}}</option>
            <option value="">{{'admin.question_bank.manage.all_category'|trans}}</option>
            {{ select_options(build_category_choices(categoryTree), app.request.get('categoryId')) }}
          </select>
        </div>
        <div class="form-group">
          <select class="form-control" name="status">
            {{ select_options(dict('courseStatus'), app.request.query.get('status'), 'admin.item_bank_exercise.exercise.manage.status_placeholder'|trans) }}
          </select>
        </div>

        <div class="form-group">
          <input class="form-control" type="text" placeholder="{{ 'admin.course_manage.title_placeholder'|trans }}" name="title" value="{{ app.request.get('title') }}">
        </div>
        <div class="form-group">
          <input class="form-control" type="text" placeholder="{{ 'admin.course_manage.creator_placeholer'|trans }}" name="creatorName" value="{{ app.request.get('creatorName') }}">
        </div>
        <button class="btn btn-primary">{{ 'form.btn.search'|trans }}</button>
      </div>
    </form>
  </div>

  <p class="text-muted">
    <span class="mrl">{{ 'admin.item_bank_exercise.manage.count'|trans({'%exerciseNum%':exercisesStatusNum.total})|raw }}</span>
    <span class="mrl">{{ 'admin.course_manage.manage.published_count'|trans({'%publishedNum%':exercisesStatusNum.published})|raw }}</span>
    <span class="mrl">{{ 'admin.course_manage.manage.closed_count'|trans({'%closedNum%':exercisesStatusNum.closed})|raw }}</span>
    <span class="mrl">{{ 'admin.course_manage.manage.unpublish_count'|trans({'%unPublishedNum%':exercisesStatusNum.draft})|raw }}</span>
  </p>

  <table class="table table-striped table-hover" id="exercise-table" style="word-break:break-all;">
    <thead>
    <tr>
      <th>{{ 'admin.item_bank_exercise.exercise.manage.number'|trans }}</th>
      <th width="20%">{{ 'admin.course_manage.manage.name'|trans }}</th>
      <th width="10%">{{ 'admin.course_manage.manage.price'|trans }}</th>
      <th>{{ 'course.item_number'|trans }}</th>
      <th>
        {{ 'admin.course_manage.manage.student_number'|trans }}
      </th>

      <th>{{ 'admin.course_manage.manage.creator'|trans }}</th>
      <th>{{ 'admin.item_bank_exercise.exercise.manage.status'|trans }}</th>
      <th width="10%">{{'admin.course_manage.operater'|trans}}</th>
    </tr>
    </thead>
    <tbody>
    {% for exercise in exercises %}
      {% set user = users[exercise.creator]|default(null) %}
      {% set category = categories[exercise.categoryId]|default(null) %}
      {% set questionBank = questionBanks[exercise.questionBankId]|default(null) %}
      {% include 'admin-v2/teach/item-bank-exercise/exercise-tr.html.twig' %}
    {% else %}
      <tr>
        <td colspan="20">
          <div class="empty">{{'admin.item_bank_exercise.exercise.manage.empty'|trans}}</div>
        </td>
      </tr>
    {% endfor %}
    </tbody>
  </table>
  {{ admin_macro.paginator(paginator) }}

{% endblock %}